/*
 * graph.h
 *
 *  Created on: 2010-5-12
 *      Author: anders
 */
#ifndef GRAPH_H_
#define GRAPH_H_

#include <glib/gtypes.h>

#undef DRAW_CURVE /*if you want to draw curve , please define DRAW_CURVE*/

#define RANDOM_DATA_DEMO 0

#define EMPTY_DATA -1.0f
#define DEFAULT_FONT_SIZE 10.0f
#define NUM_POINTS 62
#define GRAPH_MIN_HEIGHT 40;
#define FRAME_WIDTH 8

#define DEFAULT_SPEED 1000
#define MIN_MONITOR_SPEED 100

#define DEFAULT_CHANNEL_NUMBER 1
#define MAX_CHANNEL_NUMBER 10

#define DEFAULT_DATA_MIN 0.0f
#define DEFAULT_DATA_MAX 100.0f

#define MONITOR_GRAPH_FAIL
#define MONITOR_GRAPH_SUCCESS

struct _MonitorGraph;
typedef struct _MonitorGraph MonitorGraph;
typedef gint (*MONITOR_GRAPH_CALLBACK)(MonitorGraph *g, guint channel, gfloat *data);

struct _MonitorGraph {
	double fontsize;
	double rmargin;
	double indent;

	guint n;
	gint type;
	guint speed;
	guint channel;
	guint draw_width, draw_height;
	guint render_counter;
	guint frames_per_unit;
	guint graph_dely;
	guint real_draw_height;
	double graph_delx;
	guint graph_buffer_offset;
	GArray *colors;
	GArray *buttons;
	GArray *labels;
/*
	std::vector<GdkColor> colors;
	std::vector<float> data_block;
*/
	gfloat data[MAX_CHANNEL_NUMBER][NUM_POINTS];
	gfloat min;
	gfloat max;
	GtkWidget *main_widget;
	GtkWidget *disp;
	GtkWidget *box;

	GdkGC *gc;
	GdkDrawable *background;

	guint timer_index;

	gboolean draw;

	//LoadGraphLabels labels;
	GtkWidget *mem_color_picker;
	GtkWidget *swap_color_picker;
	MONITOR_GRAPH_CALLBACK callback;
};


void monitor_graph_init(MonitorGraph *g, GtkWidget *window, guint channel, guint speed, MONITOR_GRAPH_CALLBACK callback);
void monitor_graph_force_update(gpointer user_data);
void monitor_graph_data_clear(gpointer user_data);
void monitor_graph_polling_start(MonitorGraph *g);
void monitor_graph_polling_stop(MonitorGraph *g);
void monitor_graph_get_polling_speed(MonitorGraph *g, guint *speed);
gint monitor_graph_set_polling_speed(MonitorGraph *g, guint speed);
gint monitor_graph_set_data(MonitorGraph *g , gfloat min, gfloat max);
gint monitor_graph_set_channel(MonitorGraph *g, guint channel, gchar *name, gchar* color);
GtkWidget* monitor_graph_get_widget(MonitorGraph *g);

#endif /* GRAPH_H_ */
